/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author jackie
 */
@Entity
@Table(name = "event")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Event.findAll", query = "SELECT e FROM Event e"), 
    @NamedQuery(name = "Event.findAllByDateOrderByEventDate", query = "SELECT e FROM Event e WHERE e.eventDate = :eventDate ORDER BY e.eventDate DESC, e.eventID ASC"),
    @NamedQuery(name = "Event.findAllOrderByEventDate", query = "SELECT e FROM Event e ORDER BY e.eventDate DESC, e.eventID ASC"),
    @NamedQuery(name = "Event.findByUserEmail", query = "SELECT e FROM Event e WHERE e.userEmail = :userEmail ORDER BY e.eventDate DESC, e.eventID ASC"),
    @NamedQuery(name = "Event.findByEventID", query = "SELECT e FROM Event e WHERE e.eventID = :eventID"),    
    @NamedQuery(name = "Event.findByEventNameFuzzy", query = "SELECT e FROM Event e WHERE e.eventName LIKE :eventName and e.eventPublicPrivate = :eventPublicPrivate"),
    @NamedQuery(name = "Event.findByEventName", query = "SELECT e FROM Event e WHERE e.eventName = :eventName"),
    @NamedQuery(name = "Event.findByEventDesciption", query = "SELECT e FROM Event e WHERE e.eventDesciption = :eventDesciption"),
    @NamedQuery(name = "Event.findByEventDate", query = "SELECT e FROM Event e WHERE e.eventDate = :eventDate"),
    @NamedQuery(name = "Event.findByEventStartTime", query = "SELECT e FROM Event e WHERE e.eventStartTime = :eventStartTime"),
    @NamedQuery(name = "Event.findByEventEndTime", query = "SELECT e FROM Event e WHERE e.eventEndTime = :eventEndTime"),
    @NamedQuery(name = "Event.findByEventCity", query = "SELECT e FROM Event e WHERE e.eventCity = :eventCity"),
    @NamedQuery(name = "Event.findByEventIndoorOutdoor", query = "SELECT e FROM Event e WHERE e.eventIndoorOutdoor = :eventIndoorOutdoor"),
    @NamedQuery(name = "Event.findByEventPublicPrivate", query = "SELECT e FROM Event e WHERE e.eventPublicPrivate = :eventPublicPrivate"),
    @NamedQuery(name = "Event.findByEventNotification", query = "SELECT e FROM Event e WHERE e.eventNotification = :eventNotification")})
public class Event implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "eventID")
    private Collection<Invitee> inviteeCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "EventID")
    private Integer eventID;
    @Size(max = 255)
    @Column(name = "EventName")
    private String eventName;
    @Size(max = 255)
    @Column(name = "EventDesciption")
    private String eventDesciption;
    @Column(name = "EventDate")
    @Temporal(TemporalType.DATE)
    private Date eventDate;
    @Column(name = "EventStartTime")
    @Temporal(TemporalType.TIME)
    private Date eventStartTime;
    @Column(name = "EventEndTime")
    @Temporal(TemporalType.TIME)
    private Date eventEndTime;
    @Size(max = 255)
    @Column(name = "EventCity")
    private String eventCity;
    @Column(name = "EventIndoorOutdoor")
    private Boolean eventIndoorOutdoor;
    @Column(name = "EventPublicPrivate")
    private Boolean eventPublicPrivate;
    @Column(name = "EventNotification")
    private Boolean eventNotification;
    @JoinColumn(name = "UserEmail", referencedColumnName = "UserEmail")
    @ManyToOne(optional = false)
    private User userEmail;

    public Event() {
    }

    public Event(Integer eventID) {
        this.eventID = eventID;
    }

    public Integer getEventID() {
        return eventID;
    }

    public void setEventID(Integer eventID) {
        this.eventID = eventID;
    }

    public String getEventName() {
        return eventName;
    }

    public void setEventName(String eventName) {
        this.eventName = eventName;
    }

    public String getEventDesciption() {
        return eventDesciption;
    }

    public void setEventDesciption(String eventDesciption) {
        this.eventDesciption = eventDesciption;
    }

    public Date getEventDate() {
        return eventDate;
    }

    public void setEventDate(Date eventDate) {
        this.eventDate = eventDate;
    }

    public Date getEventStartTime() {
        return eventStartTime;
    }

    public void setEventStartTime(Date eventStartTime) {
        this.eventStartTime = eventStartTime;
    }

    public Date getEventEndTime() {
        return eventEndTime;
    }

    public void setEventEndTime(Date eventEndTime) {
        this.eventEndTime = eventEndTime;
    }

    public String getEventCity() {
        return eventCity;
    }

    public void setEventCity(String eventCity) {
        this.eventCity = eventCity;
    }

    public Boolean getEventIndoorOutdoor() {
        return eventIndoorOutdoor;
    }

    public void setEventIndoorOutdoor(Boolean eventIndoorOutdoor) {
        this.eventIndoorOutdoor = eventIndoorOutdoor;
    }

    public Boolean getEventPublicPrivate() {
        return eventPublicPrivate;
    }

    public void setEventPublicPrivate(Boolean eventPublicPrivate) {
        this.eventPublicPrivate = eventPublicPrivate;
    }

    public Boolean getEventNotification() {
        return eventNotification;
    }

    public void setEventNotification(Boolean eventNotification) {
        this.eventNotification = eventNotification;
    }

    public User getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(User userEmail) {
        this.userEmail = userEmail;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (eventID != null ? eventID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Event)) {
            return false;
        }
        Event other = (Event) object;
        if ((this.eventID == null && other.eventID != null) || (this.eventID != null && !this.eventID.equals(other.eventID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entity.Event[ eventID=" + eventID + " ]";
    }

    @XmlTransient
    public Collection<Invitee> getInviteeCollection() {
        return inviteeCollection;
    }

    public void setInviteeCollection(Collection<Invitee> inviteeCollection) {
        this.inviteeCollection = inviteeCollection;
    }
    
}
